package educar.utils;

import java.io.*;

public class Archivo
{
    public static void copiar(File dirOrigen, File dirDestino) throws Exception
    {

        InputStream in = new FileInputStream(dirOrigen);
        OutputStream out = new FileOutputStream(dirDestino);

        byte[] buffer = new byte[1024];
        int len;

        try
        {
            while ((len = in.read(buffer)) > 0)
            {
                out.write(buffer, 0, len);
            }
            out.flush();
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            in.close();
            out.close();
        }
    }

    public static void copiar(String dirOrigen, String dirDestino) throws Exception
    {
        InputStream in = new FileInputStream(dirOrigen);
        OutputStream out = new FileOutputStream(dirDestino);

        byte[] buffer = new byte[1024];
        int len;

        try
        {

            while ((len = in.read(buffer)) > 0)
            {
                out.write(buffer, 0, len);
            }
            out.flush();
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            in.close();
            out.close();
        }
    }
}
